
2
2
.
.
2
2
.
.
2
2
S
S
c
c
a
a
l
l
a
a
r
r
s
s
Scalar Data Types can only store single value.
Scalar Data Types
Represents undefined/unknown value.
Represents logical TRUE or FALSE.
Represents integer number (20, -54).
Represents integer number (20, -54).
Represents integer number (20, -54).
Represents integer number (20, -54).
Represents real number (-45.87).
Represents real number (-45.87).
Represents Unicode character.
Null data type can only have null value and can be created using Null Literal.
Null data type can only be assigned to reference type variable which are those that hold Classes and Strings.
You cannot assign null data to primitive variables like boolean, int, float, etc.
null
String name = null; //Create null data using null literal.
Integer age = null; //Assign null to Integer class. Different from int primitive.
int temp = null; //Error. Cannot assign null data to primitive variables.
Boolean data type can have only two possible values: true or false and can be created using Boolean Literal.
bool
boolean value = true; //Create boolean data using boolean literal.
boolean value = Boolean.getBoolean("false"); //Create boolean data using getBoolean() method.
Byte data type is type of data that represents integer number and can be created using Integer Literal.
Check out byte cheat sheet containing code samples for working with byte data type.
byte
byte value = 65; //Create byte data using long literal which is then implicitly converted to byte data.